package activity.wheelOfFortune;

import models.BaseModel;
import models.constants.DeletedStatus;
import models.merchant.Merchant;
import models.weixin.WebUser;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by LiuBin on 2016/5/13.
 */
@Entity
@Table(name = "prize_history")
public class PrizeHistory extends BaseModel {

    /**
     * 商户.
     */
    @ManyToOne
    @JoinColumn(name = "merchant_id")
    public Merchant merchant;

    /**
     * 关联的微信用户.
     */
    @ManyToOne
    @JoinColumn(name = "weixin_user_id")
    public WebUser weixinUser;

    /**
     * 抽奖原因
     */
    @Column(name = "content")
    public String content;

    /**
     * 奖品有效时间 , 天数
     */
    @Column(name = "valid_time")
    public Integer validTime ;

    /**
     * 创建时间
     */
    @Column(name = "created_at")
    public Date createdAt;

    /**
     * 当时剩余抽奖机会
     */
    @Column(name = "last_chance")
    public Integer lastChance;
    /**
     * 逻辑删除,0:未删除，1:已删除
     */
    @Enumerated(EnumType.ORDINAL)
    public DeletedStatus deleted;

    public PrizeHistory() {
        super();
    }
    public PrizeHistory(WebUser weixinUser,  String content) {
        this.weixinUser = weixinUser;
        this.content = content;
        this.createdAt = new Date();
        this.deleted = DeletedStatus.UN_DELETED;
    }
}
